<template>
    <div class="flexbetween" style="border-top:2px solid #F5F6F7;">
        <div class="inputMain padding15All">
            <el-form ref="form" :model="form" :label-width="type=='sign'?'100px':'130px'">
                <el-row :gutter="10">
                    <el-col :span="12" v-if="type=='sign'">
                        <el-form-item label="发起时间">
                            <el-date-picker
                                v-model="value"
                                type="daterange"
                                size="small"
                                range-separator="-"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                :clearable="false"
                                :default-time="['00:00:00', '23:59:59']">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" v-if="type=='sign'">
                        <el-form-item label="签署名称">
                            <el-input size="small" v-model="form.contractName" placeholder="签署名称"></el-input>
                        </el-form-item>
                    </el-col>
                    <!-- <el-col :span="6" v-if="type=='sign'">
                        <el-form-item label="发起方">
                            <el-input size="small" v-model="form.promoterEnterprise" placeholder="发起方名称/证件号/手机号"></el-input>
                        </el-form-item>
                    </el-col> -->
                    <!-- <el-col :span="6" v-if="type=='sign'&&show">
                        <el-form-item label="签署方">
                            <el-input size="small" v-model="form.name" placeholder="签署方名称/证件号/手机号"></el-input>
                        </el-form-item>
                    </el-col> -->
                    <!-- <el-col :span="6" v-if="type=='sign'&&show">
                        <el-form-item label="合同状态">
                            <el-select size="small" v-model="form.signState">
                                <el-option label="签署中" value="0"></el-option>
                                <el-option label="已完成" value="1"></el-option>
                                <el-option label="拒绝签署" value="2"></el-option>
                                <el-option label="解约中" value="3"></el-option>
                                <el-option label="已解约" value="4"></el-option>
                                <el-option label="拒绝解约" value="5"></el-option>
                                <el-option label="已撤回" value="6"></el-option>
                                <el-option label="已过期" value="7"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col> -->


                    <el-col :span="6" v-if="type=='go'">
                        <el-form-item label="申请出证业务名称">
                            <el-input size="small" v-model="form.contractName1" placeholder="申请出证业务名称"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12" v-if="type=='go'">
                        <el-form-item label="申请出证时间">
                            <el-date-picker
                                v-model="value1"
                                type="daterange"
                                size="small"
                                range-separator="-"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期">
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <div class="btnMain padding15All">
            <el-button size="small" type="primary" @click="search">查询</el-button>
            <el-button size="small" @click="reset">重置</el-button>
            <!-- <template  v-if="type=='sign'">
                <el-button @click="changeShow(1)" v-if="show" size="small" icon="el-icon-d-arrow-left" class="active close"></el-button>
                <el-button @click="changeShow(2)" v-if="!show" size="small" icon="el-icon-d-arrow-right" class="active open"></el-button>
            </template> -->
        </div>
    </div>
</template>

<script>
export default {
    props:['type'],
    data() {
        return {
            form: {
                contractName:'',//签署名称
                contractum:'',//签署编号
                initiateEndTime:'',// 发起结束时间
                initiateStartTime:'',//发起开始时间
                promoterEnterprise:'',//发起方
                signState:'',//合同状态 0 签署中 1已完成 2-拒绝签署3 解约中 4 已解约 5拒绝解约 6-已撤回 7已过期


                applyEndTime:'',//申请时间
                applyStartTime:'',//申请时间
                contractName1:'',//申请出证业务名称
            },
            value:[],
            value1:[],
            show:true,
        }
    },
    watch:{
        'value'(){
            // console.log(Number(this.value[0]));
            // console.log(this.value[0]);
            if(this.value=='[]'){
                this.form.initiateStartTime=''
                this.form.initiateEndTime=''
            }else{
                this.form.initiateStartTime=this.date(Number(this.value[0]))
                this.form.initiateEndTime=this.date(Number(this.value[1]))
            }
            
        },
        'value1'(){
            // console.log(Number(this.value1[0]));
            // console.log(this.value1[0]);
            if(this.value1=='[]'){
                this.form.applyStartTime=''
                this.form.applyEndTime=''
            }else {
                this.form.applyStartTime=this.date(Number(this.value1[0]))
                this.form.applyEndTime=this.date(Number(this.value1[1]))
            }
        }
    },
    methods: {
        date(timer) {
			var date = new Date(timer); //当前时间
			var year = date.getFullYear() //返回指定日期的年份
			var month = repair(date.getMonth() + 1); //月
			var day = repair(date.getDate()); //日
			var curTime = year + "-" + month + "-" + day
			function repair(i) {
				if (i >= 0 && i <= 9) {
					return "0" + i;
				} else {
					return i;
				}
			}
			return curTime
		},
        search() {
            this.$emit("Listsearch", this.form)
        },
        reset() {
            this.form={
                contractName:'',//签署名称
                contractum:'',//签署编号
                initiateEndTime:'',// 发起结束时间
                initiateStartTime:'',//发起开始时间
                promoterEnterprise:'',//发起方
                signState:'',//合同状态 0 签署中 1已完成 2-拒绝签署3 解约中 4 已解约 5拒绝解约 6-已撤回 7已过期


                applyEndTime:'',//申请时间
                applyStartTime:'',//申请时间
                contractName1:'',//申请出证业务名称
            }
            this.value=[]
            this.value1=[]
            this.$emit("Listsearch", this.form)
        },
        changeShow(type){
            if(type==1){
                this.show=false
            }else if(type==2){
                this.show=true
            }
        }
    }
}
</script>

<style lang="scss">
.inputMain{
    .el-select{
        width: 100%;
    }
    .el-date-editor--daterange.el-input__inner{
        width: 100%;
    }
    .el-form-item{
        margin-bottom: 16px;
    }
    .el-button--mini{
        padding:5px 7px;
    }
}
</style>

<style lang="scss" scoped>
.inputMain{
    width:80%;
    // border-top:1px solid #F5F6F7;
}
.btnMain{
    align-self: flex-start;
    // border-top:1px solid #F5F6F7;
    .active{
        transform: rotate(90deg);
        padding-left: 9px;
        padding-right: 9px;
    }
}
</style>